package com.example.myapplication

import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.example.myapplication.databinding.ActivitySecondBinding
import com.xinnuo.analytics.android.annotation.TrackViewOnClick
import com.xinnuo.delegate.viewBinding
import com.xinnuo.permission.AxPermission
import com.xinnuo.permission.annotation.Permission
import com.xinnuo.permission.annotation.PermissionDenied
import com.xinnuo.permission.consts.Constant

class SecondActivity : AppCompatActivity(R.layout.activity_second) {

    private val binding by viewBinding(ActivitySecondBinding::bind)

    private val mList = ArrayList<String>()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        MainActivity.isCompleted = true

        mList += "1111111111"
        mList += "2222222222"
        mList += "3333333333"
        mList += "4444444444"
        mList += "5555555555"
        mList -= "5555555555"

        binding.textView.text = mList.toString()

        binding.button2.setOnClickListener {
            Log.i("button", "被点击了")
            Log.i("button", mList[6])
        }
    }

    @TrackViewOnClick
    fun textOnClick(view: View) {
        //开启日志调试
        AxPermission.isdebug = true
        textClick(view)
    }

    @Suppress("UNUSED_PARAMETER")
    @Permission([Constant.G_STORAGE, Constant.G_CAMERA])
    fun textClick(view: View) {
        Toast.makeText(this, "权限请求成功", Toast.LENGTH_SHORT).show()
    }

    @PermissionDenied([Constant.G_CAMERA, Constant.G_STORAGE])
    fun onCameraDenied(deny: Array<String>) {
        Toast.makeText(this, "${deny.joinToString("，")}权限请求失败", Toast.LENGTH_SHORT).show()
    }

}